/*
 * Copyright (c) 2016- 2020 qolome.com Inc. All Rights Reserved.
 * ProjectName: qolome-knowledge
 * FileName: PayStrategy.java
 * Author: jiangfeng@qolome.com
 * Date: 2020/3/15 下午4:20
 * LastModified: 2020/03/15 16:20:15
 */

package com.qolome.knowledge.design.pattern.strategy.demo.pay;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Qolome
 * @version V1.0
 * @Description 支付策略
 * @date 2020年 03月15日 16:20:20
 */
public class PayStrategy {

    public static  final String ALI_PAY = "AliPay";
    public static  final String JD_PAY = "JdPay";
    public static  final String WECHAT_PAY = "WechatPay";
    public static  final String UNION_PAY = "UnionPay";
    public static  final String DEFAULT_PAY = "AliPay";

    private static Map<String,AbstractPayment> strategy = new HashMap<>();

    static {
        strategy.put(ALI_PAY,new AliPay());
        strategy.put(JD_PAY,new JdPay());
        strategy.put(WECHAT_PAY,new WechatPay());
        strategy.put(UNION_PAY,new UnionPay());

    }

    public  static  AbstractPayment get(String key){
        if(!strategy.containsKey(key)){
            return strategy.get(DEFAULT_PAY);
        }
        return strategy.get(key);
    }


}
